package org.finesys.common.log.config;

import org.finesys.common.log.core.aspect.LogAspect;
import org.finesys.common.log.listener.OperateLogListener;
import org.finesys.system.api.service.LogService;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;


/**
 * 日志自动配置
 */
@EnableAsync
@AutoConfiguration
@EnableConfigurationProperties(LogProperties.class)
@ConditionalOnProperty(value = "security.log.enabled", matchIfMissing = true)
public class LogAutoConfiguration {

    @Bean
    public OperateLogListener operateLogListener(LogProperties logProperties, LogService logService) {
        return new OperateLogListener(logProperties, logService);
    }


    @Bean
    public LogAspect logAspect() {
        return new LogAspect();
    }

}
